﻿using System;
using System.Collections.Generic;
using System.Web;

namespace Vbyte.SharpOrm.Config
{
    /// <summary>
    /// 表字段映射对应名称
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
    public class TableItemAttribute : Attribute
    {
        /// <summary>
        /// 初始化一个指定表名的 <see cref="TableItemAttribute"/> 实例.
        /// </summary>
        /// <param name="tableName">绑定表名</param>
        /// <param name="fieldName">绑定字段名</param>
        public TableItemAttribute(string tableName, string fieldName)
        {
            BindTable = tableName;
            BindField = fieldName;
        }

        /// <summary>
        /// 初始化一个 <see cref="TableItemAttribute"/> 实例.
        /// </summary>
        /// <param name="fieldName">绑定字段名</param>
        public TableItemAttribute(string fieldName)
        {
            BindField = fieldName;
        }

        /// <summary>
        /// 获取或设置所在的表容器
        /// </summary>
        public BindTableAttribute Container { get; set; }

        /// <summary>
        /// 获取或设置绑定表名称
        /// </summary>
        public string BindTable { get; set; }

        /// <summary>
        /// 获取或设置绑定字段名称
        /// </summary>
        public string BindField { get; set; }
    }
}